package com.base.controller;

import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.base.comm.CommContent;
import com.base.po.voip.Helpers;
import com.base.service.HelpersService;
import com.base.service.LogsService;
import com.base.utils.IP;
import com.base.utils.Produce;

/**
 * 添加反馈信息服务端
 * 
 * @author f
 *
 */
@Controller
@RequestMapping("/admin")
public class add_Help {

	@Autowired
	private LogsService logsService; // log日志
	@Autowired
	private HelpersService helpersService; // 反馈信息

	// 添加反馈信息
	@RequestMapping(value = "/toAddHelp", method = RequestMethod.POST)
	public @ResponseBody int toAddHelp(HttpServletRequest request, Helpers helpers) throws Exception {
		String userid = (String) request.getSession().getAttribute("adminUserId"); // 登录的用户ID
		if (userid == null) return -1; // 未登录
		helpers.setId(Produce.getUUID()); // 设置参数 主键ID
		helpers.setCreatetime(Produce.getNowDate()); // 发布时间
		helpers.setAgentid(userid); // 代理商ID
		helpers.setStatus(2); // 未解决状态
		helpers.setDatastatus(true); // 可用
		logsService.insert(CommContent.TYPE_CREATE, CommContent.LOGS_XIAOXI + "配置反馈中心信息",
				(String) request.getSession().getAttribute("userNick"), true, IP.getIpAddr(request)); // 记录创建日志
		return helpersService.insertSelective(helpers); // 添加
	}
}
